home *** CD-ROM | disk | FTP | other *** search
- In article <4gognf$et@news.bridge.net>,
- David Byrden <100101.2547@compuserve.com> wrote:
- ><<<<<<<
- >
- >Why is it not allowed to delegate the initialisation to another
- >constructor
- >
- >class X
- >{
- >public:
- > X (int i) : i_(i) {}
- >
- > X () : X(34) {} // Not allowed
- >>>>>>>>>>
- >
- >
- > Why not use X (int i = 34 ) : i_(i) {}
-
- >[ I think he was concerned with the more general case of a complicated
- > initialization (not assignment) that must be repeated for each
- > constructor. -sdc, moderator
- >]
-
- Well, one could use a similar thing using a member function:
-
- X (int i) { init(i); }
- X () { init(34); }
-
- where init is a member function for class X.
-
- Anders
- [ To submit articles: Try just posting with your newsreader.
- If that fails, use mailto:std-c++@ncar.ucar.edu
- FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
- Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
- Comments? mailto:std-c++-request@ncar.ucar.edu
- ]
-